package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import mode.Shape;

public class ScorePn extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int SCORENODEWIDTH=10;
	public static final int SCORENODEHEIGHT=10;
	private Shape nshape;
    private String score="0";
    private String level="3";
	
	public ScorePn() {
		// TODO Auto-generated constructor stub
		setSize(100, 500);
		setBackground(Color.lightGray);
		setBorder(BorderFactory.createEmptyBorder());
	}

	public void init(){
	    score="0";
	    level="3";
	}
	
    @Override
    public void paint(Graphics g) {
    	// TODO Auto-generated method stub
    	super.paint(g);
    	Font font=new Font("宋体", Font.BOLD, 15);
    	
    	g.setFont(font);
    	g.drawString("LEVEL:", 15, 50);
    	g.drawString(level, 15, 70);
    	g.drawString("SCORE:", 15, 130);
    	g.drawString(score, 20, 150);
    	g.drawString("NEXT:", 15, 220);
    	
    	if(nshape==null) return;
    	
    	Color color=nshape.getColor();
    	int[][] nextshape=nshape.getShape();
    	for(int i=0;i<nextshape.length;i++){
    		for(int j=0;j<nextshape[i].length;j++){
    			if(nextshape[i][j]==1){
    				g.setColor(color);
    				g.fill3DRect(15+j*SCORENODEWIDTH, 225+i*SCORENODEHEIGHT,SCORENODEWIDTH, SCORENODEHEIGHT, true);
    			}
    		}
    	}
    	
    }
	
	public void display(Shape shape) {
		// TODO Auto-generated method stub
		this.nshape=shape;
		repaint();
	}

	public void showScore(int score) {
		// TODO Auto-generated method stub
		this.score=String.valueOf(score);
		repaint();
	}
    
	public void showLevel(String level){
		this.level=level;
		repaint();
	}
}
